/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package verins.Utils;

import java.awt.event.KeyEvent;
import javax.swing.text.AttributeSet;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;

/**
 *
 * @author Hector
 */

/*****
 Esta clase limita el tamaño de los JtextField
 ******/
public class LimitInput extends PlainDocument{
private int limite=0;

    public LimitInput(int longMax) {
        super();
        limite=longMax;
    }

    @Override
    public void insertString(int offs, String str, AttributeSet a)throws BadLocationException{
        
        if (str==null) return;
             if ((getLength()+str.length())<=limite){
                super.insertString(offs,str,a);
          }
    }

}
